CREATE TABLE [dbo].[tb_Ajustes]
(
[idAjuste] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Fecha] [datetime] NOT NULL CONSTRAINT [DF_tb_Ajustes_Fecha] DEFAULT (getdate()),
[Responsable] [int] NOT NULL,
[Agente] [int] NOT NULL,
[Servicio] [int] NULL,
[Reclamo] [int] NULL,
[Tipo] [int] NOT NULL,
[ConceptoEspecifico] [int] NULL,
[AjusteDesde] [datetime] NOT NULL,
[AjusteHasta] [datetime] NOT NULL,
[PagoDescORetencion] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ManualOAutomatico] [int] NULL,
[NuevoDesde] [datetime] NULL,
[NuevoHasta] [datetime] NULL,
[NuevaCantidad] [int] NULL,
[NuevaAfiliacion] [int] NULL,
[Monto] [float] NOT NULL,
[ConceptoDeAjuste] [int] NULL,
[TopeMensualDescuento] [int] NULL,
[MontoRemanente] [int] NULL,
[UltMesDeDescuento] [int] NULL,
[Observaciones] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Ajustes] ADD CONSTRAINT [PK_tb_Ajustes] PRIMARY KEY NONCLUSTERED  ([idAjuste]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Ajustes] WITH NOCHECK ADD CONSTRAINT [FK_tb_Ajustes_tb_Agentes] FOREIGN KEY ([Agente]) REFERENCES [dbo].[tb_Agentes] ([idAgente])
GO
ALTER TABLE [dbo].[tb_Ajustes] WITH NOCHECK ADD CONSTRAINT [FK_tb_Ajustes_tb_ConceptosDeLiquidacion1] FOREIGN KEY ([ConceptoDeAjuste]) REFERENCES [dbo].[tb_ConceptosDeLiquidacion] ([idConceptoLiquidacion])
GO
ALTER TABLE [dbo].[tb_Ajustes] WITH NOCHECK ADD CONSTRAINT [FK_tb_Ajustes_tb_ConceptosDeLiquidacion] FOREIGN KEY ([ConceptoEspecifico]) REFERENCES [dbo].[tb_ConceptosDeLiquidacion] ([idConceptoLiquidacion])
GO
ALTER TABLE [dbo].[tb_Ajustes] WITH NOCHECK ADD CONSTRAINT [FK_tb_Ajustes_tb_Afiliaciones] FOREIGN KEY ([NuevaAfiliacion]) REFERENCES [dbo].[tb_Afiliaciones] ([idAfiliacion])
GO
ALTER TABLE [dbo].[tb_Ajustes] WITH NOCHECK ADD CONSTRAINT [FK_tb_Ajustes_tb_Reclamos] FOREIGN KEY ([Reclamo]) REFERENCES [dbo].[tb_Reclamos] ([idReclamo])
GO
ALTER TABLE [dbo].[tb_Ajustes] WITH NOCHECK ADD CONSTRAINT [FK_tb_Ajustes_tb_Usuarios] FOREIGN KEY ([Responsable]) REFERENCES [dbo].[tb_Usuarios] ([idUsuario])
GO
ALTER TABLE [dbo].[tb_Ajustes] WITH NOCHECK ADD CONSTRAINT [FK_tb_Ajustes_tb_TiposDeAjustes] FOREIGN KEY ([Tipo]) REFERENCES [dbo].[tb_TiposDeAjustes] ([IdTipoDeAjuste])
GO
